import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Main {

    public static void main(String[] args) {

     /*   BST<Integer> bst = new BST<>();
        int[] nums = {5, 3, 6, 8, 4, 2};
        for(int num: nums) bst.add(num);

        /////////////////
        //      5      //
        //    /   \    //
        //   3    6    //
        //  / \    \   //
        // 2  4     8  //
        /////////////////
        bst.preOrder();
        System.out.println();
        bst.preOrderNR();
        System.out.println();
        bst.inOrder();
        System.out.println();
        bst.postOrder();
        System.out.println();
        bst.levelOrder();
        System.out.println();
        System.out.println(bst);*/

        BST<Integer> bst = new BST<>();
        Random random = new Random();
        int n = 1000;
        for (int i = 0; i < n; i++) bst.add(random.nextInt(10000));
        List<Integer> nums = new ArrayList<>();
        while (!bst.isEmpty()) nums.add(bst.removeMin());
        System.out.println("nums = " + nums);
        for (int i = 1; i < nums.size(); i++)
            if (nums.get(i - 1) > nums.get(i)) throw new IllegalArgumentException("顺序异常!!!");
        System.out.println("removeMin test completed!!!");


        BST<Integer> bst1 = new BST<>();
        for (int i = 0; i < n; i++) bst1.add(random.nextInt(10000));
        List<Integer> nums1 = new ArrayList<>();
        while (!bst1.isEmpty()) nums1.add(bst1.removeMax());
        System.out.println("nums1 = " + nums1);
        for (int i = 1; i < nums1.size(); i++)
            if (nums1.get(i - 1)< nums1.get(i)) throw new IllegalArgumentException("顺序异常!!!");
        System.out.println("removeMax test completed!!!");


    }
}
